package cn.jee.jsp;

import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;
@WebServlet({"/lifecycleDemo","/lifecycle2"})
public class LifecycleDemoServlet extends HttpServlet {
  @Override
  public void init(ServletConfig config) throws ServletException {
    System.out.println("init");
  }

  @Override
  protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    PrintWriter out=resp.getWriter();
    out.println("service"+java.time.LocalDateTime.now());
  }

  @Override
  public void destroy() {//不知道什么时候运行，不要依赖于这个方法
    System.out.println("destroy");
  }
}
